home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume7 / nethack3 / patch10h < prev    next >
Encoding:
Text File  |  1991-02-08  |  40.7 KB  |  1,142 lines

  1. Subject:  v12i032:  NetHack3 -  display oriented dungeons & dragons (Ver. 3.0), Patch10h
  2. Newsgroups: comp.sources.games
  3. Approved: billr@saab.CNA.TEK.COM
  4.  
  5. Submitted-by: Izchak Miller <izchak@linc.cis.upenn.edu>
  6. Posting-number: Volume 12, Issue 32
  7. Archive-name: NetHack3/Patch10h
  8. Patch-To: NetHack3: Volume 7, Issue 56-93
  9. Environment: 
  10.  
  11.  
  12.  
  13. #! /bin/sh
  14. # This is a shell archive.  Remove anything before this line, then unpack
  15. # it by saving it into a file and typing "sh file".  To overwrite existing
  16. # files, type "sh file -c".  You can also feed this as standard input via
  17. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  18. # will see the following message at the end:
  19. #        "End of archive 8 (of 8)."
  20. # Contents:  Install.mac others/exesmurf.c others/exesmurf.doc
  21. #   src/lev_main.c
  22. # Wrapped by billr@saab on Fri Feb  8 17:19:03 1991
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'Install.mac' -a "${1}" != "-c" ; then 
  25.   echo shar: Renaming existing file \"'Install.mac'\" to \"'Install.mac.orig'\"
  26.   mv -f 'Install.mac' 'Install.mac.orig'
  27. fi
  28. echo shar: Extracting \"'Install.mac'\" \(15825 characters\)
  29. sed "s/^X//" >'Install.mac' <<'END_OF_FILE'
  30. XMacintosh NetHack 3.0 (Patchlevel 10) Installation Guide
  31. Xlast modified: January 27th, 1991
  32. X(A fixed width font is recommended for this document, Courier 10)
  33. X
  34. X
  35. XAcknowledgements
  36. X================
  37. XOriginal credit for porting NetHack 3.0 to the Macintosh goes to Johnny
  38. XLee and Michael Sokolov.  David Hairston, Kevin Sitze, Andy Swanson, Jon
  39. XWatte and Tom West helped polish this port in later versions.
  40. X
  41. X
  42. XPreliminary Notes
  43. X================
  44. XThese instructions are optimized for the Think C 4.0 compiler.  Other
  45. XMacintosh compilers should be okay however some work will be needed to
  46. Xcomplete the build.  For other compilers that use "make", you can use the
  47. Xvarious Makefiles and your compiler errors as guides in building the game.
  48. X
  49. XYou should maintain the file/folder structure given in the distribution
  50. Xfile "Files".  These notes assume that file structure which is outlined
  51. Xbelow. Place the "top" folder appropriately in your compilers development
  52. Xfolder.  You'll need ~6MB disk space for Macintosh only development,
  53. Xhowever you will use less space by cleaning up after each phase of the
  54. Xbuild detailed below.
  55. X
  56. X
  57. XDistribution File Structure (Think C 4.0)
  58. X================
  59. Xtop {folder, appropriately placed in Think C 4.0 development tree}
  60. X    Files
  61. X    Install.mac
  62. X    Makefile.top        {if you need Makefiles, Think C 4.0 doesn't}
  63. X    auxil {folder}
  64. X        all auxiliary support files.
  65. X    include {folder}
  66. X        all header files.
  67. X    mac {folder}
  68. X        all Macintosh specific files.
  69. X    others {folder}
  70. X        pcconf.c, pcmain.c, pctty.c & random.c only.
  71. X        **** remove this copy of lev_lex.c! ****
  72. X    src {folder}
  73. X        all source files.
  74. X        **** keep this copy of lev_lex.c! ****
  75. X
  76. X
  77. XNon-Think C 4.0 Users
  78. X================
  79. XIf your compiler doesn't handle subfolders you'll need to place all the
  80. Xinter-related source (*.c) and header (*.h) files in a common folder. It
  81. Xwill require some work but you should be able to follow the dependencies
  82. Xin the Makefiles to build the game.
  83. X
  84. XIf your compiler utilizes the make/Makefile facilities, then remove the
  85. Xtags from the Makefiles (auxil, src and top) and edit appropriately.
  86. X
  87. X
  88. XGetting Started
  89. X================
  90. XUsers of Think C 4.0 should decode the 5 BinHex 4.0 encoded *.hqx files in
  91. Xthe mac folder, thus creating 3 Think C project files and 2 associated
  92. XResEdit resource files.  There are various BinHex 4.0 decoders which can
  93. Xdo this, including the applications BinHex 4.0 and Stuffit and the desk
  94. Xaccessory BinHqx DA 1.02.  Move the 5 extracted files (makedefs.proj,
  95. Xmakedefs.proj.rsrc, sp_lev.proj, nethack.proj and nethack.proj.rsrc) to
  96. Xthe "top" folder.
  97. X
  98. XUse your favorite text editor to create an empty file of type "TEXT".
  99. XName this file "news" and save it in the auxil folder. If you decide to
  100. Xuse the NEWS compile option (recommended) then write a message in the
  101. X"news" file which may get displayed at the start of every game.
  102. X
  103. XCreate a folder called "Dungeon" in the "top" folder. This is where we'll
  104. Xplace the files needed to run NetHack.
  105. X
  106. XFinally, Think C 4.0 users should have no problem compiling the NetHack
  107. Xsources, as distributed.  If you make changes to the sources then consider
  108. Xbacking up your disk to prevent problems.  Also, trash (or alter the
  109. Xcreator signature of) older versions of NetHack 3.0 to avoid conflicts.
  110. X
  111. XOkay, let's get started.  We're going to make 3 applications, in order:
  112. X(1) makedefs, to create customized files for the game, (2) spec_lev, to
  113. Xcreate special challenging maze-like levels and (3) nethack!  The full
  114. Xbuild from scratch takes about an hour using Think C 4.0 .
  115. X
  116. X
  117. XMacintosh Configuration
  118. X================
  119. XEdit the header file "config.h" (in the include folder) as follows.  The
  120. Xchanges below occur sequentially.  Scan forward to find:
  121. X
  122. X * Section 1:    OS selection.
  123. X
  124. XComment out: #define UNIX
  125. XUncomment  : #define MACOS {bottom of the ifdef __MSDOS__ else clause}.
  126. X
  127. XScan forward to the segment:
  128. X
  129. X#ifdef MACOS
  130. X#define THINKC4        /* for the Think C 4.0 compiler */
  131. X
  132. XNote that marginal support has been provided for other compilers but it
  133. Xwill take some work to complete the build using those compilers.  This
  134. Xsegment is configured properly for Think C 4.0 users, by default.  If your
  135. Xcompiler doesn't handle the "defined(x)" compiler directive then you
  136. Xshould define "KR1ED", this is done automatically here for LSC and AZTEC.
  137. X
  138. XScan forward to:
  139. X
  140. X * Section 2:    Some global parameters and filenames.
  141. X
  142. XChange "izchak" to a suitable wizard id.  A good choice is "wizard".
  143. XThis is the name that needs to appear in the NetHack "Set Options..."
  144. Xdialog in order to enable the selection of wizard (debug) mode.
  145. X
  146. XComment out: #define LOGFILE "logfile"
  147. X
  148. XScan forward to:
  149. X
  150. X * Section 3:    Definitions that may vary with system type.
  151. X
  152. XThe configuration here is okay for THINKC4, LSC and AZTEC.
  153. X     
  154. XScan forward to:
  155. X
  156. X * Section 4:  THE FUN STUFF!!!
  157. X
  158. XThe defines here default to configuring a full-featured game.  If you want
  159. Xa current indicator of your score during play (recommended) then
  160. X
  161. XUncomment:   #define SCORE_ON_BOTL
  162. X
  163. XSave the config.h file.
  164. X
  165. XIf you customize the game then look at the header files macconf.h and
  166. Xsystem.h. This isn't necessary for simply building the default game.
  167. X
  168. X
  169. XBuilding Makedefs
  170. X================
  171. XMakedefs depends on the source files:
  172. X    alloc.c  macfile.c  makedefs.c  monst.c  objects.c  panic.c
  173. X
  174. XThink C 4.0 users should open the project file "makedefs.proj".  Others
  175. Xshould refer to Makefile.src for help.
  176. X
  177. XWe need to re-configure for makedefs so Open the header file "config.h".
  178. XScan forward (in Section 1) to:
  179. X
  180. X#ifdef MACOS
  181. X
  182. XComment out: #define CUSTOM_IO .
  183. XUncomment  : #define MAKEDEFS_C .
  184. X
  185. XClose and save the config.h file.
  186. X
  187. XBuild the makedefs application. The Think C 4.0 project uses resources
  188. Xfrom the "makedefs.proj.rsrc" file.
  189. X
  190. XSave the application in the "top" folder and Close the project.
  191. X
  192. XRun the makedefs application, sequentially choosing all seven options.
  193. XThis will require re-launching each time.  You've now created additional
  194. Xauxiliary files for the game and added icons and signatures to these 12
  195. Xfiles (in the auxil folder): cmdhelp, data, help, hh, history, license,
  196. XMacHelp, news, opthelp, oracles, record, and rumors. These files should be
  197. Xcopied into the "Dungeon" folder.
  198. X
  199. XIf you decide to change features in the game, remember to always rebuild
  200. Xmakedefs first to setup the needed data structures and so on for the game.
  201. X
  202. X
  203. XBuilding Spec_levs
  204. X================
  205. XThis application depends on the source files:
  206. X    alloc.c      lev_comp.c  lev_lex.c   lev_main.c
  207. X    macfile.c    monst.c     objects.c   panic.c
  208. X
  209. XIf you copied the alternate file others:lev_lex.c, you should remove it
  210. Xnow to avoid problems with src:lev_lex.c.
  211. X
  212. XThink C 4.0 users should open the project file "spec_lev.proj".  Others
  213. Xshould refer to Makefile.src for help.
  214. X
  215. XThe changes needed to build this application are more complicated than
  216. Xbefore, however the checklist provided below should cover all the bases.
  217. XWe need to re-configure for spec_levs (and subsequently for NetHack) so
  218. XOpen the header file "config.h".
  219. X
  220. XScan forward (in Section 1) to:
  221. X
  222. X#ifdef MACOS
  223. X
  224. XComment out: #define MAKEDEFS_C
  225. X
  226. XClose and save the header file "config.h".
  227. X
  228. XOpen the source file (in the src folder) "lev_lex.c".  Make the following
  229. Xchanges, which appear sequentially:
  230. X    Find                                    Replace with
  231. X    {... near the beginning ...}
  232. X    int yyleng; extern char yytext[];       int yyleng; extern char *yytext;
  233. X    int yymorfg;                            int yymorfg;
  234. X    extern char *yysptr, yysbuf[];          extern char *yysptr, *yysbuf;
  235. X    int yytchar;                            int yytchar;
  236. X    FILE *yyin ={stdin}, *yyout ={stdout};  FILE *yyin =stdin, *yyout =stdout;
  237. X    {... near the end ...}
  238. X    {... If you're using LSC or THINKC4 comment out: ...}
  239. X    {... #define NLSTATE yyprevious=YYNEWLINE ...}
  240. X    char yytext[YYLMAX];                    char *yytext;
  241. X    {... Skip a line ...}
  242. X    char yysbuf[YYLMAX];                    char *yysbuf;
  243. X    char *yysptr = yysbuf;                  char *yysptr;
  244. X
  245. XScan backward (near the beginning) to:
  246. X
  247. X#define MONDATA_H    /* comment this line for pre-compiled headers */
  248. X#define MONFLAG_H    /* comment this line for pre-compiled headers */
  249. X
  250. XComment out: #define MONDATA_H and MONFLAG_H
  251. X
  252. XCut the line:
  253. X
  254. X#include "hack.h"
  255. X
  256. Xand Paste it back in again at the very beginning of the file!
  257. X
  258. XSave the changes to lev_lex.c and close the file.
  259. X
  260. XOpen the source file, "lev_comp.c".
  261. X
  262. XScan forward to:
  263. X
  264. X#define MONDATA_H    /* comment this line for pre-compiled headers */
  265. X#define MONFLAG_H    /* comment this line for pre-compiled headers */
  266. X
  267. XComment out: #define MONDATA_H and MONFLAG_H
  268. X
  269. XCut the line:
  270. X
  271. X#include "hack.h"
  272. X
  273. Xand Paste it back in again at the very beginning of the file!
  274. X
  275. XScan forward (near the middle of the file) and make this change:
  276. X    Find                                    Replace with
  277. X    #endif not lint                         #endif /* not lint */
  278. X
  279. XSave the changes to lev_comp.c and close the file.
  280. X
  281. XFinally, we need to block some compiler directives in the source files
  282. X"alloc.c" and "panic.c" in order to use pre-compiled headers.
  283. X
  284. XOpen the source file "alloc.c".
  285. X
  286. XComment out: #define ALLOC_C and EXTERN_H
  287. X
  288. XSave the changes to alloc.c and close the file.
  289. X
  290. XOpen the source file "panic.c".
  291. X
  292. XComment out: #define NEED_VARARGS
  293. X
  294. XSave the changes to panic.c and close the file.
  295. X
  296. XNow we need to prepare the pre-compiled header files "hack.h"
  297. Xand "config.h".  We'll do this again in the NetHack project.
  298. X
  299. XShell out to the Finder and _copy_ the files hack.h and config.h
  300. Xto pre_hack.h and pre_config.h, respectively.  Be careful not to
  301. Xlose these files as you'll need them to complete the build.  Switch
  302. Xback to the compiler.
  303. X
  304. XOpen the file "pre_hack.h".  Choose the Source menu option Precompile
  305. Xand save the resulting file as "hack.h" (overwriting the old hack.h).
  306. XOpen the file "pre_config.h" and Precompile it saving the result as
  307. X"config.h" (again overwrite the old config.h).
  308. X
  309. XBuild the spec_lev application and save it into the "top" folder.  Close
  310. Xthe spec_lev project.
  311. X
  312. XBefore running the spec_lev application let's restore the pre-compiled
  313. Xheader files.  Trash "hack.h" and "config.h".  Now rename "pre_hack.h" and
  314. X"pre_config.h" to "hack.h" and "config.h", respectively.
  315. X
  316. XRun the spec_lev application, it will show you what file it is currently
  317. Xworking on and create the 5 special levels: castle, endgame, tower1,
  318. Xtower2 and tower3 in the top folder. These 5 files should be moved into
  319. Xthe Dungeon folder.
  320. X
  321. XIf you're motivated to create customized special levels it should be
  322. Xpossible to modify the special level compiler to accommodate your efforts.
  323. XYou'll also want to edit the "descrip[]" and "argc" variables, in
  324. Xlev_main.c within the ifdef MACOS segments, to get the compiler to
  325. Xrecognize your custom levels.  You probably won't bother (no one has)!
  326. X
  327. XIf you decide to change features in the game, remember to always rebuild
  328. Xspec_levs to reflect those changes in the special level files.
  329. X
  330. X
  331. XBuilding NetHack
  332. X================
  333. XThis is what you've been waiting for!  The file "Segments.mac" shows the
  334. Xsource dependencies for this application and suggests a workable scheme
  335. Xfor creating properly sized segments.
  336. X
  337. XThink C 4.0 users should open the project file "nethack.proj".  Others
  338. Xshould refer to the various Makefiles for help.
  339. X
  340. XThe checklist below indicates the changes needed to build the game.
  341. X
  342. XOpen the header file "config.h".
  343. X
  344. XScan forward (in Section 1) to:
  345. X
  346. X#ifdef MACOS
  347. X
  348. XUncomment:   #define CUSTOM_IO
  349. X
  350. XSave the changes to config.h and close the file.
  351. X
  352. XOpen the source file, "topten.c".
  353. X
  354. XScan forward to:
  355. X
  356. X#define MONATTK_H    /* comment line for pre-compiled headers */
  357. X#define MONFLAG_H    /* comment line for pre-compiled headers */
  358. X
  359. XComment out: #define MONATTK_H and MONFLAG_H
  360. X
  361. XScan forward to:
  362. X
  363. X#define    POINTSMIN    1    /* must be > 0 */
  364. X#define    ENTRYMAX    100    /* must be >= 10 */
  365. X
  366. XChange POINTSMIN to 51 and ENTRYMAX to 50 to reduce the size and
  367. Xclutter in the record file.
  368. X
  369. XComment out: #define PERS_IS_UID
  370. X
  371. XClose topten.c and save the changes.
  372. X
  373. XThink C 4.0 users are going to, again, use pre-compiled headers and
  374. Xthis requires a minor lexical change to the files listed below.  We'll
  375. Xuse a feature from the Search menu to make this operation easier.
  376. X
  377. XFiles needing a lexical change for pre-compiled headers:
  378. Xapply.c     end.c       extralev.c  mkroom.c    mon.c       monmove.c
  379. Xpager.c     pctty.c     pri.c       priest.c    save.c      shk.c
  380. Xsounds.c    termcap.c   topl.c
  381. X
  382. XInvoke the "Find" command from the "Search" menu. Enter these fields:
  383. X    Search For:                            Replace with:
  384. X    ^\(#.*pre-compiled headers \*\/\)      /*\1
  385. X
  386. XCheck the "Grep" and "Multi-File Search" check boxes (you'll be
  387. Xlooking in all .c files) then click the "Don't Find" button.
  388. X
  389. XNow repeat this sequence:
  390. X1) Select "Find in Next File" from the "Search" menu.
  391. X2) When it finally makes a match, Select "Replace All".
  392. X3) Click the "Okay" button in the ensuing alert and then close and save
  393. X    the file.  Now go back to (1), until there are no more matches.
  394. X
  395. XShell out to the Finder and then _copy_ the files hack.h and config.h to
  396. Xpre_hack.h. and pre_config.h, respectively.  Switch back to the compiler.
  397. X
  398. XOpen the file "pre_hack.h" and Precompile it, saving the result as "hack.h"
  399. X(overwriting the old hack.h).  Open the file "pre_config.h" and Precompile
  400. Xit, saving the result as "config.h" (overwriting the old config.h).
  401. X
  402. XOpen the "Options" dialog (under the Edit menu) and choose the
  403. X"Code Generation" radio button.  Look to be sure that "MacHeaders" is
  404. X_not_ being automatically being included in the project (unchecked).
  405. XAlso, make sure that the other options here are set to your liking.
  406. X
  407. XBuild the application, this make take a few minutes. Save the game into
  408. Xthe dungeon folder. Close the nethack project and you're ready to play the
  409. Xgame (I hope all went well).
  410. X
  411. X
  412. XMiscellaneous Notes
  413. X================
  414. XLow Memory:
  415. XIf you are attempting to build NetHack 3.0 on a 1M Macintosh using Think C
  416. X4.0, then memory may be a problem.  It is suggested that you turn off
  417. Xdebugging info for monst.c and objects.c .  Also, if for some reason,
  418. Xcompilation stops in the segment containing these two files after they
  419. Xhave been compiled, then you should drag these two files into a separate
  420. Xsegment, finish compiling the files of the original segment and then
  421. Xrestore these two files to the original segment.  Alternatively, you may
  422. Xdecide to "Kompile" monst.c and objects.c separately while preserving the
  423. Xgiven segmentation scheme.
  424. X
  425. XCleanup:
  426. XIt's a good idea to always rebuild the makedefs and spec_lev applications
  427. Xfrom scratch.  Therefore you can trash these applications and also remove
  428. Xthe objects from their respective projects (Think C compilers) to conserve
  429. Xdisk space.  The same can be done for your nethack project. Consider the
  430. Xchanges outlined above and undo them as needed to rebuild the project, if
  431. Xyou decide to modify the game.  If you're satisfied with the "default"
  432. Xgame you can trash all the files for a real saving!
  433. X
  434. XCompatibility:
  435. XYou should trash bones and save files from previous versions since they
  436. Xwill not work with this version.  The single exception is that pl9 bones
  437. Xand saves work with pl10.  Generally, record files will always work however
  438. Xnew scores may have a different format.  It may be more convenient to start
  439. Xfresh with a new scoreboard (record file) for each patchlevel.
  440. X
  441. XExtra Memory:
  442. XIf you can afford the RAM space you might consider giving the game a 1M
  443. Xpartition in Multifinder instead of the default 750k.
  444. X
  445. XSupport:
  446. XBug reports should be submitted to the InterNet e-mail address:
  447. Xnethack-bugs@linc.cis.upenn.edu
  448. X
  449. XWe, the members of the Macintosh NetHack Development Team, hope you enjoy
  450. Xthe game. We've worked hard at porting and polishing it to make it behave
  451. Xin the Macintosh way!
  452. END_OF_FILE
  453. if test 15825 -ne `wc -c <'Install.mac'`; then
  454.     echo shar: \"'Install.mac'\" unpacked with wrong size!
  455. fi
  456. # end of 'Install.mac'
  457. if test -f 'others/exesmurf.c' -a "${1}" != "-c" ; then 
  458.   echo shar: Renaming existing file \"'others/exesmurf.c'\" to \"'others/exesmurf.c.orig'\"
  459.   mv -f 'others/exesmurf.c' 'others/exesmurf.c.orig'
  460. fi
  461. echo shar: Extracting \"'others/exesmurf.c'\" \(13430 characters\)
  462. sed "s/^X//" >'others/exesmurf.c' <<'END_OF_FILE'
  463. X/******************************************************************************
  464. X*                                                                             *
  465. X*                         EXE header list and modify                          *
  466. X*                                                                             *
  467. X*                        by Pierre Martineau, 91/01/29                        *
  468. X*                                                                             *
  469. X*                                Version 1.2                                  *
  470. X*                                                                             *
  471. X>*****************************************************************************<
  472. X* Modified (stephen@estragon.uchicago.edu):                                   *
  473. X* 1990oct23 sps Overlay splitter-outer first cut                              *
  474. X*        31     Error handling; some #defines                                 *
  475. X*     nov01     /l                                                            *
  476. X*   91jan29     Changed default overlay file names to conform to ovlmgr 30a0  *
  477. X******************************************************************************/
  478. X
  479. X#include <string.h>
  480. X#include <stdlib.h>
  481. X#include <stdio.h>
  482. X#include <math.h>
  483. X
  484. X/** parameters ***************************************************************/
  485. X#define MAXFILENAME 128   /* Probably overkill - theoretical limit is 80     */
  486. X#define NPARTS        36      /* Maximum # of overlay files (excluding root .EXE)*/
  487. X#define COPYBUFSIZE 32768 /* Fair sized buffer for file copy                 */
  488. X#define BAKEXT      ".BAK"/* Extension for .exe backups                      */
  489. X#define OVLEXT      ".OVL"/* Default extension for overlay files             */
  490. X/* #define MANYZEROES */  /* Old style default: foo00001.ovl, not foo0.ovl   */
  491. X/*****************************************************************************/
  492. X
  493. X#define BOOLEAN int
  494. X#define TRUE    1
  495. X#define FALSE   0
  496. X
  497. Xint sstrccnt(register char const *s, register char c)
  498. X  { int n = 0;
  499. X
  500. X    while (*s) if (*s++ == c) n++;
  501. X    return n;
  502. X  }
  503. X
  504. XFILE *wrkfile, *outfile;
  505. Xlong min, max, stk;
  506. XBOOLEAN listflg = FALSE;
  507. XBOOLEAN verbose = FALSE;
  508. XBOOLEAN minflg = FALSE;
  509. XBOOLEAN maxflg = FALSE;
  510. XBOOLEAN stkflg = FALSE;
  511. X
  512. Xint column = 0;
  513. X
  514. Xstruct exehdr {
  515. Xunsigned signature;
  516. Xunsigned mod512;
  517. Xunsigned pages;
  518. Xunsigned relocitems;
  519. Xunsigned headerparas;
  520. Xunsigned minalloc;
  521. Xunsigned maxalloc;
  522. Xunsigned ss;
  523. Xunsigned sp;
  524. Xunsigned checksum;
  525. Xunsigned ip;
  526. Xunsigned cs;
  527. Xunsigned relocptr;
  528. Xunsigned ovlnum;
  529. X} exehdr_area;
  530. X
  531. Xmain(argc, argv)
  532. Xint argc;
  533. Xchar *argv[];
  534. X{
  535. Xchar *dot, *slash;
  536. Xchar fname[MAXFILENAME], oname[MAXFILENAME], zname[MAXFILENAME];
  537. Xchar *jname = NULL;
  538. Xchar *args;
  539. Xint i;
  540. Xlong offset, oldstk;
  541. Xunsigned nparts = 0, part = 0, partstart[NPARTS + 2];
  542. X
  543. X    printf("EXE list and modify V1.1s, by Pierre Martineau, 90/05/20.\n");
  544. X    printf("This program may be freely distributed.\n");
  545. X
  546. X    if ((argc < 2) || (argc > NPARTS + 2)) {
  547. X        usage();
  548. X        return;
  549. X    }
  550. X
  551. X/*  Process any remaining arguments  */
  552. X
  553. X    if (argc == 2) {
  554. X        listflg = TRUE;
  555. X        verbose = TRUE; /* ??? */
  556. X    }
  557. X    else {
  558. X        i = 2;
  559. X        while (argc-- > 2) {
  560. X            args = argv[i];
  561. X        if ('0' <= args[0] && args[0] <= '9') { /* File split request */
  562. X            if (nparts >= NPARTS) {
  563. X            printf("\nToo many .OVL files requested (max. %d)\n", NPARTS);
  564. X            usage();
  565. X            return;
  566. X        }
  567. X        else if (!atoi(args)) {
  568. X            printf("\nCan't relocate the root overlay (#0)\n");
  569. X            usage();
  570. X            return;
  571. X        }
  572. X        else if (nparts && partstart[nparts - 1] >= atoi(args)) {
  573. X            printf("\nOverlay starts must be in ascending order\n");
  574. X            usage();
  575. X            return;
  576. X        }
  577. X        partstart[nparts++] = atoi(args);
  578. X        } else {
  579. X        if ((args[0] != '-') && (args[0] != '/')) {
  580. X            printf("\nInvalid switch in paramater %s!\n", argv[i]);
  581. X            usage();
  582. X            return;
  583. X        }
  584. X        args++;
  585. X        if (strnicmp(args, "min", 3) == 0) {
  586. X            args += 3;
  587. X            min = atol(args);
  588. X            minflg = TRUE;
  589. X        }
  590. X        else if (strnicmp(args, "max", 3) == 0) {
  591. X            args += 3;
  592. X            max = atol(args);
  593. X            maxflg = TRUE;
  594. X        }
  595. X        else if (strnicmp(args, "stk", 3) == 0) {
  596. X            args += 3;
  597. X            stk = atol(args);
  598. X            stkflg = TRUE;
  599. X        }
  600. X        else if (strnicmp(args, "v", 1) == 0) {
  601. X            listflg = TRUE;
  602. X                    verbose = TRUE;
  603. X                }
  604. X                else if (strnicmp(args, "l", 1) == 0)
  605. X                    listflg = TRUE;
  606. X                else if (strnicmp(args, "p", 1) == 0) {
  607. X                    args++;
  608. X                    jname = args;
  609. X                }
  610. X        else {
  611. X            printf("\nInvalid paramater %s!\n", argv[i]);
  612. X            usage();
  613. X            return;
  614. X        }
  615. X            }
  616. X            i++;
  617. X        }
  618. X    }
  619. X
  620. X/*  Extract filename from first argumemt  */
  621. X
  622. X    strcpy(fname, argv[1]);
  623. X    dot = strrchr(fname, '.');
  624. X    slash = strrchr(fname, '\\');
  625. X    if ((dot == NULL) || (slash > dot))
  626. X        strcat(fname, ".exe");
  627. X
  628. X    if (nparts) {
  629. X    strcpy(oname,fname);
  630. X    *strrchr(fname, '.') = '\0';
  631. X    strcat(fname,BAKEXT);
  632. X    if (!stricmp(oname,fname)) {
  633. X        printf(
  634. X                "\nI refuse to split a file with extension "BAKEXT": %s\n",
  635. X                oname
  636. X            );
  637. X        return;
  638. X    }
  639. X        if (!jname || nparts > 1 && !sstrccnt(jname, '?')) {
  640. X            char ext[5];
  641. X            char *t;
  642. X
  643. X            if (!jname) {
  644. X                strcpy(zname, oname);
  645. X                *strrchr(zname, '.') = '\0';
  646. X                strcpy(ext, OVLEXT);
  647. X            } else {
  648. X                if (strrchr(jname, '.') &&
  649. X                     (!strrchr(jname, '\\') ||
  650. X                         strrchr(jname, '.') > strrchr(jname, '\\')
  651. X                     )
  652. X                ) {
  653. X                    strncpy(ext, strrchr(jname, '.'), sizeof(ext));
  654. X                    ext[sizeof(ext) - 1] = '\0';
  655. X                    strncpy(zname, jname, strrchr(jname, '.') - jname);
  656. X                    zname[strrchr(jname, '.') - jname] = '\0';
  657. X                } else {
  658. X                    strcpy(zname, jname);
  659. X                    strcpy(ext, OVLEXT);
  660. X                }
  661. X            }
  662. X            t = strrchr(zname, '\\') ? strrchr(zname, '\\') + 1:
  663. X                strrchr(zname, ':') ? strrchr(zname, ':') + 1:
  664. X                zname;
  665. X            if (strlen(t) >= 8)
  666. X                t[7] = '\0';
  667. X#if defined(MANYZEROES)
  668. X        while (strlen(t) < 8)
  669. X#endif
  670. X          strcat(t, "?");
  671. X            strcat(zname, ext);
  672. X            jname = zname;
  673. X        }
  674. X    if (rename(oname,fname)) { /* This assumes oldname, newname.
  675. X                      There's some confusion. OK for TC2.0 */
  676. X        printf("\nCouldn't rename (original) %s to %s\n", oname, fname);
  677. X        return;
  678. X    }
  679. X    if ((outfile = fopen(oname, "wb")) == NULL) {
  680. X            printf("\nCouldn't create file %s\n",oname);
  681. X            return;
  682. X        }
  683. X    }
  684. X
  685. X    if ((wrkfile = fopen(fname, "r+b")) == NULL) {
  686. X        printf("\nCouldn't open file %s\n", fname);
  687. X        return;
  688. X    }
  689. X
  690. X    fread(&exehdr_area, sizeof (struct exehdr), 1, wrkfile);
  691. X    if (exehdr_area.signature != 0x5a4d) {
  692. X        printf("\nNot an EXE file!\n");
  693. X        return;
  694. X    }
  695. X
  696. X    while(!feof(wrkfile)) {
  697. X        if (nparts) {
  698. X        if (exehdr_area.ovlnum == partstart[part]) {
  699. X             fclose(outfile);
  700. X                 {
  701. X                     int p = part + 1;
  702. X                     strcpy(oname, jname);
  703. X                     while (sstrccnt(oname, '?') > 1) {
  704. X                         *strrchr(oname, '?') = '0' + p % 10;
  705. X                         p /= 10;
  706. X                     }
  707. X                     *strchr(oname, '?') = (p > 9 ? 'a' - 10 : '0') + p;
  708. X                 }
  709. X                 part++;
  710. X         if ((outfile = fopen(oname, "wb")) == NULL) {
  711. X                     printf("\nCan't open file %s\n", oname);
  712. X                     return;
  713. X                 }
  714. X        }
  715. X            fwrite(&exehdr_area, sizeof (struct exehdr), 1, outfile);
  716. X            if (ferror(outfile)) {
  717. X                printf("\nWrite error while moving overlay header in %s\n", oname);
  718. X                return;
  719. X            }
  720. X    }
  721. X        if (listflg)
  722. X            show_hdr();
  723. X        else if (nparts)
  724. X            printf("[overlay %d]\r", exehdr_area.ovlnum); /* Keep talking... */
  725. X        if ((minflg || maxflg || stkflg) && (exehdr_area.ovlnum == 0) && (exehdr_area.signature == 0x5a4d)) {
  726. X            if (minflg)
  727. X                exehdr_area.minalloc = min;
  728. X            if (maxflg)
  729. X                exehdr_area.maxalloc = max;
  730. X            if (stkflg) {
  731. X                oldstk = exehdr_area.sp;
  732. X                exehdr_area.sp = stk;
  733. X                if (!minflg) {
  734. X                    exehdr_area.minalloc += ((stk - oldstk) / 16);
  735. X                    printf("\nAdjusting size of minalloc!\n");
  736. X                }
  737. X            }
  738. X            fseek(nparts ? outfile : wrkfile, ftell(wrkfile) - sizeof (struct exehdr), SEEK_SET);
  739. X            fwrite(&exehdr_area, sizeof (struct exehdr), 1, nparts ? outfile : wrkfile);
  740. X            if (ferror(nparts ? outfile : wrkfile)) {
  741. X                printf("Write error while trying to update header!\n");
  742. X                fclose(nparts ? outfile : wrkfile);
  743. X                return;
  744. X            }
  745. X        }
  746. X        offset = exehdr_area.pages;
  747. X        offset *= 512L;
  748. X        offset -= sizeof(struct exehdr);
  749. X        if (nparts) { /* Copy the stuff across */
  750. X        static char buffer[COPYBUFSIZE];
  751. X        while (offset > sizeof(buffer)) {
  752. X             fread(buffer, sizeof(buffer), 1, wrkfile);
  753. X                 if (ferror(wrkfile)) {
  754. X                     printf("\nRead error in overlay body\n");
  755. X                     return;
  756. X                 }
  757. X         fwrite(buffer, sizeof(buffer), 1, outfile);
  758. X                 if (ferror(outfile)) {
  759. X                     printf("\nWrite error moving overlay body, file %s\n", oname);
  760. X                     return;
  761. X                 }
  762. X         offset -= sizeof(buffer);
  763. X        }
  764. X        fread(buffer, (unsigned)offset, 1, wrkfile);
  765. X            if (ferror(wrkfile)) {
  766. X                printf("\nRead error in overlay body\n");
  767. X                return;
  768. X            }
  769. X            fwrite(buffer, (unsigned)offset, 1, outfile);
  770. X            if (ferror(outfile)) {
  771. X                printf("\nWrite error moving overlay body, file %s\n", oname);
  772. X                return;
  773. X            }
  774. X        } else fseek(wrkfile, offset, SEEK_CUR);
  775. X        fread(&exehdr_area, sizeof (struct exehdr), 1, wrkfile);
  776. X        if (ferror(wrkfile)) {
  777. X            printf("Read error while trying to get a header!\n");
  778. X            fclose(wrkfile);
  779. X            return;
  780. X        }
  781. X    }
  782. X    if (nparts) {
  783. X        fclose(outfile);
  784. X        if (!listflg) printf("                    \r");
  785. X    }
  786. X    fclose(wrkfile);
  787. X    if (listflg && !verbose && column % 4) printf("\n");
  788. X}
  789. X
  790. Xshow_hdr()
  791. X{
  792. Xlong lsize;
  793. X
  794. X    lsize = exehdr_area.pages;
  795. X    if (exehdr_area.mod512 != 0)
  796. X        lsize--;
  797. X    lsize *= 512L;
  798. X    lsize += exehdr_area.minalloc * 16;
  799. X    lsize += exehdr_area.mod512;
  800. X    lsize -= exehdr_area.headerparas * 16;
  801. X
  802. X    if (verbose) {
  803. X        printf("\nOverlay: %d\n", exehdr_area.ovlnum);
  804. X        printf("Size (512 byte pages)\t-%6x\t\t%6u\n", exehdr_area.pages, exehdr_area.pages);
  805. X        printf("Remainder (last page)\t-%6x\t\t%6u\n", exehdr_area.mod512, exehdr_area.mod512);
  806. X        printf("Header size (in paras)\t-%6x\t\t%6u\n", exehdr_area.headerparas, exehdr_area.headerparas);
  807. X        printf("Minalloc (in paras)\t-%6x\t\t%6u\n", exehdr_area.minalloc, exehdr_area.minalloc);
  808. X        printf("Maxalloc (in paras)\t-%6x\t\t%6u\n", exehdr_area.maxalloc, exehdr_area.maxalloc);
  809. X        printf("Load size (in bytes)\t-%6lx\t\t%6lu\n", lsize, lsize);
  810. X        printf("Relocation items\t-%6x\t\t%6u\n", exehdr_area.relocitems, exehdr_area.relocitems);
  811. X        printf("Relocation table offset\t-%6x\t\t%6u\n", exehdr_area.relocptr, exehdr_area.relocptr);
  812. X        printf("Checksum\t\t-%6x\t\t%6u\n", exehdr_area.checksum, exehdr_area.checksum);
  813. X        printf("Initial CS:IP\t\t-  %04x:%04x\n", exehdr_area.cs, exehdr_area.ip);
  814. X        printf("Initial SS:SP\t\t-  %04x:%04x\n", exehdr_area.ss, exehdr_area.sp);
  815. X    } else {
  816. X        if (!exehdr_area.ovlnum) {
  817. X            printf("\nOverlay: %d\n", exehdr_area.ovlnum);
  818. X            printf("Minalloc (in paras)\t-%6x\t\t%6u\n", exehdr_area.minalloc, exehdr_area.minalloc);
  819. X            printf("Maxalloc (in paras)\t-%6x\t\t%6u\n", exehdr_area.maxalloc, exehdr_area.maxalloc);
  820. X            printf("Stored size (in bytes)\t-%6lx\t\t%6lu\n", exehdr_area.pages * 512L, exehdr_area.pages * 512L);
  821. X            printf("Load size (in bytes)\t-%6lx\t\t%6lu\n", lsize, lsize);
  822. X            printf("Initial CS:IP, SS:SP\t-  %04x:%04x\t  %04x:%04x\n", exehdr_area.cs, exehdr_area.ip, exehdr_area.ss, exehdr_area.sp);
  823. X    } else {
  824. X        static bis = 0;
  825. X        if (!bis++)
  826. X                printf("\nOvl StrdSz LoadSz | Ovl StrdSz LoadSz | Ovl StrdSz LoadSz | Ovl StrdSz LoadSz\n");
  827. X            printf("%3d:%6lu %6lu%s", exehdr_area.ovlnum, exehdr_area.pages * 512L, lsize, ++column % 4 ? " | " : "\n");
  828. X        }
  829. X    }
  830. X}
  831. X
  832. Xusage()
  833. X{
  834. X    printf("\nUsage: exesmurf exe_file [/l] [/v] [/min#####] [/max#####] [/stk#####]\n");
  835. X    printf("                [n1 n2...nn] [/p????????.???]\n");
  836. X    printf("       where: min   = minalloc\n");
  837. X    printf("              max   = maxalloc\n");
  838. X    printf("              stk   = stack size\n");
  839. X    printf("              ##### = decimal number of paragraphs\n");
  840. X    printf("              ni    = overlay starting each new .OVL file, n1 < n2 <...< nn\n");
  841. X    printf("              p     = DOS filename, maybe with ?s, for overlay files.\n");
  842. X}
  843. END_OF_FILE
  844. if test 13430 -ne `wc -c <'others/exesmurf.c'`; then
  845.     echo shar: \"'others/exesmurf.c'\" unpacked with wrong size!
  846. fi
  847. # end of 'others/exesmurf.c'
  848. if test -f 'others/exesmurf.doc' -a "${1}" != "-c" ; then 
  849.   echo shar: Renaming existing file \"'others/exesmurf.doc'\" to \"'others/exesmurf.doc.orig'\"
  850.   mv -f 'others/exesmurf.doc' 'others/exesmurf.doc.orig'
  851. fi
  852. echo shar: Extracting \"'others/exesmurf.doc'\" \(4793 characters\)
  853. sed "s/^X//" >'others/exesmurf.doc' <<'END_OF_FILE'
  854. X             PC NetHack Support Utilities
  855. X             ============================
  856. X             Last revision: 1991January29
  857. X
  858. XThis file contains documentation for the NetHack MS-DOS support
  859. Xutility EXESMURF.EXE.  This utility examines and modifies the load
  860. Xparameters of an .EXE file and can be used to split .OVL files off a
  861. Xmonolithic overlaid executable using ovlmgr.
  862. X
  863. XEXESMURF
  864. X--------
  865. Xexesmurf FILENAME[.EXT] /v
  866. Xexesmurf FILENAME[.EXT] /minN
  867. Xexesmurf FILENAME[.EXT] /maxN
  868. Xexesmurf FILENAME[.EXT] /l
  869. Xexesmurf FILENAME[.EXT] N... [/pPATTERN]
  870. X
  871. XThe programme exesmurf is basically a reimplementation of Microsoft's
  872. XEXEMOD utility.  However, this incarnation is one that is
  873. X"overlay-aware" (as they say).  It will provide the user with
  874. Xinformation about the executable and its overlays, and allow you to
  875. Xmodify the executable's parameters and overlay locations.
  876. X
  877. XThis program is made available for all users who were not graced with a
  878. Xrelease of EXEMOD in their Microsoft product, or who need the
  879. Xadditional functionality it provides.
  880. X
  881. X/v.
  882. XIf exesmurf is invoked with a filename as argument, optionally
  883. Xfollowed by a /v, the filename's exeheader is listed for your viewing
  884. Xpleasure, along with the headers of any Microsoft-format overlays the
  885. Xfile may contain.  The listing is verbose; if there are many overlays
  886. Xyou will want to redirect the output.  Note that the redundancy in the
  887. Xoutput listing largely reflects redundancy in the file structure.
  888. X
  889. X/minN, /maxN, /stackN.
  890. XExesmurf may also be used to modify the "minalloc", "maxalloc" and
  891. X"stack" allocation parameters of the executable file.  This can be
  892. Xaccomplished with the /min, /max, and /stack flags respectively.  Any
  893. Xarguments to these flags should be *immediately* followed by a decimal
  894. Xnumber N.  Note that this is inconsistent with the arguments to EXEMOD
  895. Xwhich takes hex numbers, and *needs* a space between the flag and the
  896. Xnumber.
  897. X
  898. X/l.
  899. XThe /l option requests a version of the /v listing (see above) in
  900. Xwhich the information about overlays is very much compressed; only
  901. Xtheir decimal file and load sizes are given, in a multi-column format.
  902. XThe resulting display will generally fit on a single screen.  This
  903. Xturns out to be very useful when contemplating appropriate parameters
  904. Xfor the overlay splitting operation described next.
  905. X
  906. XN... [/pPATTERN].
  907. XThe overlay-unpacking function of exesmurf is invoked by following the
  908. Xfilename argument by a sequence of decimal numbers.  Each of these
  909. Xnumbers is an overlay number at which a new external overlay file is
  910. Xto be started.  The main executable file will keep its old name after
  911. Xthe overlays have been unloaded; the original input file will be
  912. Xretained, with its extension changed to .BAK.  By default, the output
  913. Xfiles will be derived from the input file name by appending a
  914. Xdiscriminating character (in sequence, 0, 1, ..., 9, a, b, ..., z) to
  915. Xthe basename and changing the extension to .OVL; but if the basename
  916. Xis a full 8 characters long, the discriminating character will replace
  917. Xthe last character instead.  This default is chosen for compatibility
  918. Xwith ovlmgr.  The default may be overridden with the /p option, which
  919. Xspecifies a file PATTERN - a file name, possibly complete with
  920. Xextension, containing one or more ? characters (* is not allowed),
  921. Xwhich will be replaced by discriminating characters.  If there is
  922. Xexactly one questionmark, it will be replaced by a digit or letter in
  923. Xthe sequence described above, but if more than one questionmark
  924. Xappears a decimal numbering scheme is used instead.
  925. X    Note that the numeric arguments are overlay numbers, not
  926. Xindices, and they indicate the starting overlays of files.  This
  927. Xpermits us to manipulate files in which (for some reason) the overlays
  928. Xare not stored in ascending order, but it does mean that if a
  929. Xmentioned overlay does not exist in the original file, no new overlay
  930. Xfile will be started.  This is a realistic risk, since the Microsoft
  931. Xlinker does not seem to generate overlays at all if there is no actual
  932. Xcode generated into the segments in question.
  933. X    Note further that this operation can be reversed with the DOS
  934. Xcopy/b operation, always supposing that it works as documented in your
  935. Xrelease of the operating system: the overlays are simply moved
  936. Xpage-by-page to the external files.
  937. X    No guarantees are made as to how this programme will behave if
  938. Xthere is debug information or other strangeness stored after the last
  939. Xoverlay in the file.
  940. X
  941. XWhenever exesmurf is invoked, the extension .EXE is assumed for the
  942. Xfile if no extension is given.  Other extensions are probably only
  943. Xmeaningful for examining overlay files.
  944. X----------------------------------------------------------------------
  945. XStephen P Spackman                       stephen@estragon.uchicago.edu
  946. X----------------------------------------------------------------------
  947. END_OF_FILE
  948. if test 4793 -ne `wc -c <'others/exesmurf.doc'`; then
  949.     echo shar: \"'others/exesmurf.doc'\" unpacked with wrong size!
  950. fi
  951. # end of 'others/exesmurf.doc'
  952. if test -f 'src/lev_main.c' -a "${1}" != "-c" ; then 
  953.   echo shar: Renaming existing file \"'src/lev_main.c'\" to \"'src/lev_main.c.orig'\"
  954.   mv -f 'src/lev_main.c' 'src/lev_main.c.orig'
  955. fi
  956. echo shar: Extracting \"'src/lev_main.c'\" \(3435 characters\)
  957. sed "s/^X//" >'src/lev_main.c' <<'END_OF_FILE'
  958. X/*    SCCS Id: @(#)lev_main.c    3.0    89/07/02
  959. X/*    Copyright (c) 1989 by Jean-Christophe Collet */
  960. X/* NetHack may be freely redistributed.  See license for details. */
  961. X
  962. X/*
  963. X * This file contains the main function for the parser
  964. X * and some useful functions needed by yacc
  965. X */
  966. X
  967. X#include "hack.h"
  968. X
  969. X#ifdef MSDOS
  970. X# undef exit
  971. X# ifndef AMIGA
  972. Xextern void FDECL(exit, (int));
  973. X# endif
  974. X#endif
  975. X#ifdef LATTICE
  976. Xlong *alloc(unsigned int);
  977. X# ifdef exit
  978. X#  undef exit
  979. X# endif
  980. X#include <stdlib.h>
  981. X#endif
  982. X
  983. X#define MAX_ERRORS    25
  984. X
  985. Xextern int line_number;
  986. Xchar *fname = "(stdin)";
  987. Xint fatal_error = 0;
  988. X
  989. X/* Flex 2.3 bug work around */
  990. Xint yy_more_len = 0;
  991. X
  992. Xint  FDECL (main, (int, char **));
  993. Xint  NDECL (yyparse);
  994. Xvoid FDECL (yyerror, (char *));
  995. Xvoid FDECL (yywarning, (char *));
  996. Xint  NDECL (yywrap);
  997. Xvoid FDECL (init_yyin, (FILE *));
  998. Xvoid FDECL (init_yyout, (FILE *));
  999. X
  1000. X#ifdef LSC
  1001. X# define main _main
  1002. X#endif
  1003. Xmain(argc, argv)
  1004. Xint argc;
  1005. Xchar **argv;
  1006. X{
  1007. X    FILE *fin;
  1008. X    int i;
  1009. X
  1010. X#if defined(MACOS) && defined(SMALLDATA)
  1011. X# ifdef THINKC4
  1012. X#include <console.h>
  1013. X# endif
  1014. X#define YYLMAX    2048
  1015. X    extern char    *yysbuf, *yytext, *yysptr;
  1016. X    Handle temp;
  1017. X    Str255 name;
  1018. X    long    j;
  1019. X    extern struct permonst *mons;
  1020. X    extern struct objclass *objects;
  1021. X    /* 3 special level description files */
  1022. X    char *descrip[] = {"lev_comp", ":auxil:castle.des",
  1023. X            ":auxil:endgame.des", ":auxil:tower.des"};
  1024. X
  1025. X    /* sub in the Nethack resource filename */
  1026. X    Strcpy((char *)name, "\021nethack.proj.rsrc");
  1027. X    yysbuf = (char *)alloc(YYLMAX);
  1028. X    yysptr = yysbuf;
  1029. X    yytext = (char *)alloc(YYLMAX);
  1030. X
  1031. X    (void)OpenResFile(name);
  1032. X    temp = GetResource(HACK_DATA, MONST_DATA);
  1033. X    if (temp) {
  1034. X        DetachResource(temp);
  1035. X        MoveHHi(temp);
  1036. X        HLock(temp);
  1037. X        i = GetHandleSize(temp);
  1038. X        mons = (struct permonst *)(*temp);
  1039. X    } else {
  1040. X        panic("Can't get MONST resource data.");
  1041. X    }
  1042. X    
  1043. X    temp = GetResource(HACK_DATA, OBJECT_DATA);
  1044. X    if (temp) {
  1045. X        DetachResource(temp);
  1046. X        MoveHHi(temp);
  1047. X        HLock(temp);
  1048. X        i = GetHandleSize(temp);
  1049. X        objects = (struct objclass *)(*temp);
  1050. X        for (j = 0; j< NROFOBJECTS+1; j++) {
  1051. X            objects[j].oc_name = sm_obj[j].oc_name;
  1052. X            objects[j].oc_descr = sm_obj[j].oc_descr;
  1053. X        }
  1054. X    } else {
  1055. X        panic("Can't get OBJECT resource data.");
  1056. X    }
  1057. X    argc = 4;    /* argv[0] is irrelevant, argv[i] = descrip[i] */
  1058. X    argv = descrip;
  1059. X#endif  /* !MACOS || !SMALLDATA */
  1060. X
  1061. X    init_yyout(stdout);
  1062. X    if (argc == 1) {        /* Read standard input */
  1063. X        init_yyin(stdin);
  1064. X        yyparse();
  1065. X    } else {            /* Otherwise every argument is a filename */
  1066. X        for(i=1; i<argc; i++) {
  1067. X            fname = argv[i];
  1068. X#ifdef MACOS
  1069. X            fprintf(stdout, "Working on %s\n", fname);
  1070. X#endif
  1071. X            fin = freopen(fname, "r", stdin);
  1072. X            if (!fin) {
  1073. X            fprintf(stderr,"Can't open \"%s\" for input.\n", fname);
  1074. X            perror(fname);
  1075. X            } else {
  1076. X            init_yyin(fin);
  1077. X            yyparse();
  1078. X            }
  1079. X            line_number = 1;
  1080. X            fatal_error = 0;
  1081. X        }
  1082. X    }
  1083. X#ifndef VMS
  1084. X    return 0;
  1085. X#else
  1086. X    return 1;       /* vms success */
  1087. X#endif /*VMS*/
  1088. X}
  1089. X
  1090. X/* 
  1091. X * Each time the parser detects an error, it uses this function.
  1092. X * Here we take count of the errors. To continue farther than
  1093. X * MAX_ERRORS wouldn't be reasonable.
  1094. X */
  1095. X
  1096. Xvoid yyerror(s)
  1097. Xchar *s;
  1098. X{
  1099. X    fprintf(stderr,"%s : line %d : %s\n",fname,line_number, s);
  1100. X    if (++fatal_error > MAX_ERRORS) {
  1101. X        fprintf(stderr,"Too many errors, good bye!\n");
  1102. X        exit(1);
  1103. X    }
  1104. X}
  1105. X
  1106. X/* 
  1107. X * Just display a warning (that is : a non fatal error)
  1108. X */
  1109. X
  1110. Xvoid yywarning(s)
  1111. Xchar *s;
  1112. X{
  1113. X    fprintf(stderr,"%s : line %d : WARNING : %s\n",fname,line_number,s);
  1114. X}
  1115. X
  1116. Xyywrap()
  1117. X{
  1118. X       return 1;
  1119. X}
  1120. END_OF_FILE
  1121. if test 3435 -ne `wc -c <'src/lev_main.c'`; then
  1122.     echo shar: \"'src/lev_main.c'\" unpacked with wrong size!
  1123. fi
  1124. # end of 'src/lev_main.c'
  1125. echo shar: End of archive 8 \(of 8\).
  1126. cp /dev/null ark8isdone
  1127. MISSING=""
  1128. for I in 1 2 3 4 5 6 7 8 ; do
  1129.     if test ! -f ark${I}isdone ; then
  1130.     MISSING="${MISSING} ${I}"
  1131.     fi
  1132. done
  1133. if test "${MISSING}" = "" ; then
  1134.     echo You have unpacked all 8 archives.
  1135.     rm -f ark[1-9]isdone
  1136. else
  1137.     echo You still need to unpack the following archives:
  1138.     echo "        " ${MISSING}
  1139. fi
  1140. ##  End of shell archive.
  1141. exit 0
  1142.